package com.huanletao.spring.aop;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
 * <p>
 *
 * </p>
 *
 * @package: com.huanletao.spring.aop
 * @Description:
 * @className: BeanConfig
 * @author: @NNCSKJ ADMIN
 * @copyright: Copyright (c) 2022/6/26 16:30
 * @version: V1.0
 */

@EnableAspectJAutoProxy(proxyTargetClass = true,exposeProxy = true)
@Configuration
@ComponentScan("com.huanletao.spring.aop")
public class BeanConfig {


    /**
     * 突然发现，不用配置这个类，也可以实现aop 再springboot中；
     * @return
     */
//    @Bean
//    public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator(){
//        DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
//        defaultAdvisorAutoProxyCreator.setExposeProxy(true);
//        defaultAdvisorAutoProxyCreator.setProxyTargetClass(true);
//        return defaultAdvisorAutoProxyCreator;
//    }

    @Bean
    public PermissionMethodInterceptorAdvisor permissionMethodInterceptorAdvisor(){
        PermissionMethodInterceptorAdvisor advisor = new PermissionMethodInterceptorAdvisor();
        return advisor;
    }

}
